from django.db import models
from MySQLdb.constants.ER import PRIMARY_CANT_HAVE_NULL
from django.conf.global_settings import TIME_ZONE

# Create your models here.

class Registration(models.Model):
    rollno= models.CharField(max_length=15,primary_key=True)
    name= models.CharField(max_length=45)    
    emailID= models.EmailField()
    def __unicode__(self):
        return self.rollno
    
class Quiz(models.Model):
    quiz_Name=models.CharField(max_length=45)
    quiz_start_date_time=models.DateTimeField()
    quiz_end_date_time=models.DateTimeField()
    duration=models.TimeField()
    def __unicode__(self):
        return self.quiz_Name
    
class Questions(models.Model):
    quiz=models.ForeignKey(Quiz)
    question=models.TextField()
    option1=models.TextField()
    option2=models.TextField()
    option3=models.TextField()
    option4=models.TextField()
    check_box=models.CharField(max_length=4)
    radio=models.CharField(max_length=4)
    answer=models.CharField(max_length=4)
    def __unicode__(self):
        return self.question
    
class Attempted(models.Model):
    quiz_name=models.ForeignKey(Quiz)
    rollno=models.ForeignKey(Registration)
    question=models.ForeignKey(Questions)
    ansbyuser=models.CharField(max_length=3)
    Result=models.CharField(max_length=4)
    def __unicode__(self):
        return self.ansbyuser